package com.ruoyi.web.controller.alarmmanagement;

import com.ruoyi.alarmmanagement.entity.WXAlarm;
import com.ruoyi.alarmmanagement.entity.WXAlarmReqVO;
import com.ruoyi.alarmmanagement.service.IDmWarnService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.PageDomain;
import com.ruoyi.common.core.page.WeChatTableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 告警Controller
 *
 * @author ruoyi
 * @date 2023-09-06
 */
@RestController
@RequestMapping("/api/AlarmData")
public class DmWarnController extends BaseController
{
    @Autowired
    private IDmWarnService dmWarnService;

    @GetMapping("/GetAlarmStatisticsData")
    @PreAuthorize("@ss.hasPermi('alarmmanagement:warn:list')")
    public Map<String,Integer> GetAlarmStatisticsData(@RequestParam(value = "operatorId",required = false)Integer operatorId){
        return dmWarnService.GetAlarmStatisticsData();
    }



    @PostMapping("/GetAllAlarmsWithJsonForPage")
    @PreAuthorize("@ss.hasPermi('alarmmanagement:warn:list')")
    public WeChatTableDataInfo GetAlarmList(@RequestBody WXAlarmReqVO alarmReqVO){
        PageDomain pageDomain = startWeChatPage();
        List<WXAlarm> wxAlarms = dmWarnService.GetAlarmList(alarmReqVO);
        return getWeChatDataTable(wxAlarms,pageDomain);
    }
}
